﻿App.KnowledgedetailtypeCreatetypeRoute = Ember.Route.extend({
    model: function (params) {
        return App.store.createRecord(App.KnowledgeDetailType);
    },
    renderTemplate: function (controller, model) {
        controller.set('content', model);
        this.render('knowledgeDetailType/edit', {
            controller: controller
        });
    },
    actions: {
        save: function (model) {
            var that = this;
            model.set('KnowledgeType_ID', Type().id);

            Ember.$.model.add('KnowledgeDetailType', model, function (id) {
                model.set('id', id);
                model.save();

                that.controllerFor('KnowledgeDetailType').transitionTo('knowledgedetailtype', Type().Name);
            });
        }
    }
});

App.KnowledgedetailtypeEdittypeRoute = Ember.Route.extend({
    model: function (params) {
		return this.store.find(App.KnowledgeDetailType, params.knowledgeDetailType_id);
    },
    renderTemplate: function (controller, model) {
        controller.set('content', model);
        this.render('knowledgeDetailType/edit', {
            controller: controller
        });
    },
	actions: {
		save: function (model) {
		    var that = this;
		    model.set('KnowledgeType_ID', Type().id);

		    Ember.$.model.mod('KnowledgeDetailType', model, function (id) {
		        model.save();

		        that.controllerFor('KnowledgeDetailType').transitionTo('knowledgedetailtype', Type().Name);
		    });
		}
	}
});